package io.kimmking.gateway.config;

import com.google.common.collect.Lists;
import io.kimmking.gateway.ratelimiter.RateLimiterConfigEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

import java.util.List;

@ConfigurationProperties(prefix = "spring.cloud.gateway.ratelimit")
@Validated
@Slf4j
public class RateLimteConfig{

    private List<RateLimiterConfigEntity> rateLimitConfigs = Lists.newLinkedList();

    public List<RateLimiterConfigEntity> getRateLimitConfigs() {
        return rateLimitConfigs;
    }

    public void setRateLimitConfigs(List<RateLimiterConfigEntity> rateLimitConfigs) {
        this.rateLimitConfigs = rateLimitConfigs;
        if (rateLimitConfigs != null && !rateLimitConfigs.isEmpty()){
            log.info("has read RateLimiterConfigs from bootstrap.yml");
        }
    }
}
